﻿using GDPView.Database;
using GDPView.Dto;
using GDPView.Models;
using Microsoft.EntityFrameworkCore;

namespace GDPView.Services
{
    public class SampleDataRepository : ISampleDataRepository
    {
        private readonly AppDbContext _context;
        public SampleDataRepository(AppDbContext context)
        {
            _context = context;
        }
        public async Task<SampleDataDto> GetSampleDatasAsync(int pageIndex, int pageSize)
        {
            var datas = await _context.SampleDatas.ToListAsync();
            var pagination = new PaginationHelper<SampleData>(pageIndex, pageSize, datas);
            var result = new SampleDataDto();
            result = new SampleDataDto()
            {
                TotalCount = pagination.TotalCount,
                pageData = (IEnumerable<SampleData>)pagination.Items.Skip(pagination.PageIndex).Take(pagination.PageSize).ToList(),
            };
            return result;
        }
    }
}
